//
//  YTStashRecordsDetailsTableViewCell.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/11/18.
//

#import "YTStashRecordsDetailsTableViewCell.h"

@interface YTStashRecordsDetailsTableViewCell ()

@property (nonatomic ,strong) UILabel * titleLab;
@property (nonatomic ,strong) UILabel * areaName;
@property (nonatomic ,strong) UILabel * addressName;
@property (nonatomic ,strong) UILabel * shelfNumber;
@property (nonatomic ,strong) UILabel * number;
@property (nonatomic ,strong) UILabel * numberMSlab;
@property (nonatomic ,strong) UILabel * expiratDate;
@property (nonatomic ,strong) UIView * tempview;

@property (nonatomic ,strong) UILabel * deliveryName;

@property (nonatomic ,strong) UILabel * storemanName;
@property (nonatomic ,strong) UILabel * storemanNameMSLab;
@property (nonatomic ,strong) UILabel * createTime;
@property (nonatomic ,strong) UILabel * createTimeMSLab;
@property (nonatomic ,strong) UILabel * createBy;



@end

@implementation YTStashRecordsDetailsTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    self.contentView.clipsToBounds = YES;
    
    UIView * makeView = [UIView new];
    makeView.backgroundColor = UIColor.whiteColor;
    [self.contentView addSubview:makeView];
    [makeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kwt(10));
        make.right.left.bottom.offset(0);
    }];
    
    UILabel * titleLab = [DTKTool labelWithText:@"--" andFont:kCFont(17) andTextColor:KcolorHex(@"#222222")];
    self.titleLab = titleLab;
    [makeView addSubview:titleLab];
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(12));
        make.top.offset(kwt(16));
        make.height.offset(kwt(17));
    }];
    
    UILabel * temp1 = [DTKTool labelWithText:@"仓库区域" andFont:kFont(16) andTextColor:KcolorHex(@"#787A79")];
    [makeView addSubview:temp1];
    [temp1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kwt(48));
        make.height.offset(kwt(16));
        make.left.offset(kwt(12));
    }];
    
    UILabel * areaName = [DTKTool labelWithText:@"--" andFont:kFont(16) andTextColor:KcolorHex(@"#222222")];
    [makeView addSubview:areaName];
    self.areaName = areaName;
    areaName.numberOfLines = 0;
    [areaName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(temp1);
        make.left.offset(kwt(102));
        make.width.offset(kwt(270));
        make.height.offset(kwt(16));
    }];
    
    UILabel * temp2 = [DTKTool labelWithText:@"存放位置" andFont:kFont(16) andTextColor:KcolorHex(@"#787A79")];
    [makeView addSubview:temp2];
    [temp2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(areaName.mas_bottom).offset(kwt(16));
        make.height.offset(kwt(16));
        make.left.offset(kwt(12));
    }];
    
    UILabel * addressName = [DTKTool labelWithText:@"--" andFont:kFont(16) andTextColor:KcolorHex(@"#222222")];
    [makeView addSubview:addressName];
    self.addressName = addressName;
    addressName.numberOfLines = 0;
    [addressName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(temp2);
        make.left.offset(kwt(102));
        make.width.offset(kwt(270));
        make.height.offset(kwt(16));
    }];
    
    UILabel * temp3 = [DTKTool labelWithText:@"货架编号" andFont:kFont(16) andTextColor:KcolorHex(@"#787A79")];
    [makeView addSubview:temp3];
    [temp3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(addressName.mas_bottom).offset(kwt(16));
        make.height.offset(kwt(16));
        make.left.offset(kwt(12));
    }];
    
    UILabel * shelfNumber = [DTKTool labelWithText:@"--" andFont:kFont(16) andTextColor:KcolorHex(@"#222222")];
    [makeView addSubview:shelfNumber];
    self.shelfNumber = shelfNumber;
    shelfNumber.numberOfLines = 0;
    [shelfNumber mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(temp3);
        make.left.offset(kwt(102));
        make.width.offset(kwt(270));
        make.height.offset(kwt(16));
    }];
    
    UILabel * temp4 = [DTKTool labelWithText:@"出库数量" andFont:kFont(16) andTextColor:KcolorHex(@"#787A79")];
    [makeView addSubview:temp4];
    self.numberMSlab = temp4;
    [temp4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(shelfNumber.mas_bottom).offset(kwt(16));
        make.height.offset(kwt(16));
        make.left.offset(kwt(12));
    }];
    
    UILabel * number = [DTKTool labelWithText:@"--" andFont:kFont(16) andTextColor:KcolorHex(@"#222222")];
    [makeView addSubview:number];
    self.number = number;
    number.numberOfLines = 0;
    [number mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(temp4);
        make.left.offset(kwt(102));
        make.width.offset(kwt(270));
        make.height.offset(kwt(16));
    }];
    
    UILabel * temp5 = [DTKTool labelWithText:@"保质日期" andFont:kFont(16) andTextColor:KcolorHex(@"#787A79")];
    [makeView addSubview:temp5];
    [temp5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(number.mas_bottom).offset(kwt(16));
        make.height.offset(kwt(16));
        make.left.offset(kwt(12));
    }];
    
    UILabel * expiratDate = [DTKTool labelWithText:@"--" andFont:kFont(16) andTextColor:KcolorHex(@"#222222")];
    [makeView addSubview:expiratDate];
    self.expiratDate = expiratDate;
    expiratDate.numberOfLines = 0;
    [expiratDate mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(temp5);
        make.left.offset(kwt(102));
        make.width.offset(kwt(270));
        make.height.offset(kwt(16));
    }];
    
    UILabel * temp10 = [DTKTool labelWithText:@"交货人" andFont:kFont(16) andTextColor:KcolorHex(@"#787A79")];
    [makeView addSubview:temp10];
    [temp10 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(expiratDate.mas_bottom).offset(kwt(16));
        make.height.offset(kwt(16));
        make.left.offset(kwt(12));
    }];
    
    UILabel * deliveryName = [DTKTool labelWithText:@"--" andFont:kFont(16) andTextColor:KcolorHex(@"#222222")];
    [makeView addSubview:deliveryName];
    self.deliveryName = deliveryName;
    deliveryName.numberOfLines = 0;
    [deliveryName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(temp10);
        make.left.offset(kwt(102));
        make.width.offset(kwt(270));
        make.height.offset(kwt(16));
    }];
    
    UIView * tempview = [UIView new];
    tempview.backgroundColor = UIColor.whiteColor;
    [makeView addSubview:tempview];
    self.tempview = tempview;
    [tempview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(deliveryName.mas_bottom).offset(kwt(16));
        make.left.right.offset(0);
    }];
    
    
    UILabel * temp6 = [DTKTool labelWithText:@"领用人" andFont:kFont(16) andTextColor:KcolorHex(@"#787A79")];
    self.storemanNameMSLab = temp6;
    [tempview addSubview:temp6];
    [temp6 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.height.offset(kwt(16));
        make.left.offset(kwt(12));
    }];
    
    UILabel * storemanName = [DTKTool labelWithText:@"--" andFont:kFont(16) andTextColor:KcolorHex(@"#222222")];
    [tempview addSubview:storemanName];
    self.storemanName = storemanName;
    storemanName.numberOfLines = 0;
    [storemanName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(temp6);
        make.left.offset(kwt(102));
        make.width.offset(kwt(270));
        make.height.offset(kwt(16));
    }];
    
    UILabel * temp7 = [DTKTool labelWithText:@"出库时间" andFont:kFont(16) andTextColor:KcolorHex(@"#787A79")];
    self.createTimeMSLab = temp7;
    [tempview addSubview:temp7];
    [temp7 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(storemanName.mas_bottom).offset(kwt(16));
        make.height.offset(kwt(16));
        make.left.offset(kwt(12));
    }];
    
    UILabel * createTime = [DTKTool labelWithText:@"--" andFont:kFont(16) andTextColor:KcolorHex(@"#222222")];
    [tempview addSubview:createTime];
    self.createTime = createTime;
    createTime.numberOfLines = 0;
    [createTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(temp7);
        make.left.offset(kwt(102));
        make.width.offset(kwt(270));
        make.height.offset(kwt(16));
        make.bottom.offset(0);
    }];
    
    
    UILabel * temp8 = [DTKTool labelWithText:@"操作人" andFont:kFont(16) andTextColor:KcolorHex(@"#787A79")];
    [makeView addSubview:temp8];
    [temp8 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(tempview.mas_bottom).offset(kwt(16));
        make.height.offset(kwt(16));
        make.left.offset(kwt(12));
    }];
    
    UILabel * createBy = [DTKTool labelWithText:@"--" andFont:kFont(16) andTextColor:KcolorHex(@"#222222")];
    [makeView addSubview:createBy];
    self.createBy = createBy;
    createBy.numberOfLines = 0;
    [createBy mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(temp8);
        make.left.offset(kwt(102));
        make.width.offset(kwt(270));
        make.height.offset(kwt(16));
    }];
}
- (void)setModel:(YTStashRecordModel *)model {
    _model = model;
    if(model.type == 0){//入库
        self.titleLab.text = @"入库信息";
        self.numberMSlab.text = @"入库数量";
        [self.tempview mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.deliveryName.mas_bottom).offset(kwt(16));
            make.left.right.offset(0);

        }];
        self.storemanNameMSLab.text = @"仓管员";
        self.storemanName.text = model.storemanName;
        self.createTimeMSLab.text = @"入库时间";
    } else if(model.type == 1){//出库
        self.titleLab.text = @"出库信息";
        self.numberMSlab.text = @"出库数量";
        [self.tempview mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.expiratDate);
            make.left.right.offset(0);

        }];
        self.storemanNameMSLab.text = @"领用人";
        self.storemanName.text = model.createBy;
        self.createTimeMSLab.text = @"出库时间";
    }
    
    self.areaName.text = model.areaName;
    [self.areaName mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.offset(model.areaNameH);
    }];
    self.addressName.text = model.addressName;
    [self.addressName mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.offset(model.addressNameH);
    }];
    self.shelfNumber.text = model.shelfNumber;
    [self.shelfNumber mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.offset(model.shelfNumberH);
    }];
    self.number.text = [NSString stringWithFormat:@"%lu", model.number];
    self.expiratDate.text = model.expiratDate;
    self.createTime.text = model.createTime;
    self.createBy.text = model.createBy;
    self.deliveryName.text = model.deliveryName;
}
@end
